-- Viral Resistance - T-Engine 4 Module
-- Copyright (C) 2010 Mikolai Fajer
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.
--
-- Mikolai Fajer "yufra"
-- mfajer@gmail.com

local DamageType = require "engine.DamageType"

-- Fleeing from hostiles when injured
newAI("injured_flee", function(self)
	if self:runAI(self.ai_state.ai_target or "target_simple_check_hostility") then
		-- Flee if injured
		if self.life / self.max_life < (self.ai_state.wimpy or 0.5) then
			self:runAI("flee_dmap")
		else
			self:runAI("move_dmap")
		end
		return true
	end
end)

-- AI for emergency light bulbs
-- This needs work since this permanently sets the tiles as lit, instead of each turn
-- Maybe a nice shader?
newAI("light", function(self)
	-- Eventually some flickering?
	return true
end)